//
//  ArticlesTo.swift
//  weile
//
//  Created by LKM on 16/10/17.
//  Copyright © 2016年 LKM. All rights reserved.
//

import Foundation
import SwiftyJSON


//lkm
class ArticlesTo: NSObject {
    
    var pagesize: Int?;//100000
    var currentpage: Int?;//1
    var totalnum: Int?;//5
    var articlelist: [ArticlesItemTo]?;//
    var channellist: [ArticlesChannesTo]?;//
    
    //dict["data"].dictionaryObject  dict是JSON
    init?(jsons: [String: JSON]?) {
        super.init()
        
        if(jsons == nil){
            return nil
        }
        
        if let dict = jsons{
            
            self.pagesize = dict["pagesize"]?.int;//100000
            self.currentpage = dict["currentpage"]?.int;//1
            self.totalnum = dict["totalnum"]?.int;//5
            self.articlelist = ArticlesItemTo.initToList( json:dict["articlelist"]  )  ;//dict["articlelist"]  as? [ArticlesItemTo];//
            self.channellist = ArticlesChannesTo.initToList( json:dict["channellist"]  )// dict["channellist"]?.string;//
        }
    }
    
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToList(json js: JSON?)->[ArticlesTo?]?{
        if(js == nil){
            return nil;
        }
        let json = js!
        if let items = json.array {
            var results = [ArticlesTo?]()
            for item in items {
                let result = ArticlesTo(jsons: item.dictionary )
                //                if(result != nil){//空还加个屁啊  json为“[]” 时 这是不会为空的。除非直接来了个nil
                //                    results.append(result!)
                //                }
                results.append(result)
            }
            return results;
        }
        return [ArticlesTo?]()
    }
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToMap(json : JSON)->Dictionary<String,ArticlesTo>{
        
        if let items = json.dictionary {
            var results = Dictionary<String,ArticlesTo>()//取值的时候本身就是可选类型啊,所以这里不用跟数组一样弄可选类型
            for (key, value)  in items {
                let result = ArticlesTo(jsons: value.dictionary )
                results[key] = result
            }
            return results;
        }
        return Dictionary<String,ArticlesTo>()
    }
    
    
    
    
}


//lkm
class ArticlesItemTo: NSObject {
    
    var Channels: String?;//",582,"
    var AddTime: String?;//"2016/9/26 10:09:18"
    var Author: String?;//"唯乐建筑科技"
    var ClassId: Int?;//"586"
    var Click: String?;//"0"
    var Content: String?;//"微点，携手迈向新辉煌！</span></span></div>\r\n"
    var Content_e: String?;//""
    var Daodu: String?;//"结构设计师联盟、北京市建设工..."
    var Daodu_e: String?;//""
    var Form: String?;//"本站"
    var Id: String?;//"119"
    var ImgUrl: String?;//"/UpLoadFiles/20160926/2016092611224775.png"
    var IsHot: Int?;//"1"
    var IsLock: Int?;//"0"
    var IsMsg: Int?;//"1"
    var IsRed: Int?;//"1"
    var IsSlide: Int?;//"0"
    var IsTop: Int?;//"1"
    var Keyword: String?;//"第六届全国钢结构产业发展研讨会把脉行业发展"
    var Title: String?;//"第六届全国钢结构产业发展研讨会把脉行业发展"
    var Title_e: String?;//""
    var Zhaiyao: String?;//"结构设计师联盟、北京市建设工..."
    var Zhaiyao_e: String?;//""
    
    //dict["data"].dictionaryObject  dict是JSON
    init?(jsons: [String: JSON]?) {
        super.init()
        
        if(jsons == nil){
            return nil
        }
        
        if let dict = jsons{
        self.Channels = dict["Channels"]?.string;//",582,"
        self.AddTime = dict["AddTime"]?.string;//"2016/9/26 10:09:18"
        self.Author = dict["Author"]?.string;//"唯乐建筑科技"
        self.ClassId = dict["ClassId"]?.int;//"586"
        self.Click = dict["Click"]?.string;//"0"
        self.Content = dict["Content"]?.string;//"o;祝福大家在2016年，新开局、新起点，携手迈向新辉煌！</span></span></div>\r\n"
        self.Content_e = dict["Content_e"]?.string;//""
        self.Daodu = dict["Daodu"]?.string;//"会此次大会由全国钢结构设计师联盟、北京市建设工..."
        self.Daodu_e = dict["Daodu_e"]?.string;//""
        self.Form = dict["Form"]?.string;//"本站"
        self.Id = dict["Id"]?.string;//"119"
        self.ImgUrl = dict["ImgUrl"]?.string;//"/UpLoadFiles/20160926/2016092611224775.png"
        self.IsHot = dict["IsHot"]?.int;//"1"
        self.IsLock = dict["IsLock"]?.int;//"0"
        self.IsMsg = dict["IsMsg"]?.int;//"1"
        self.IsRed = dict["IsRed"]?.int;//"1"
        self.IsSlide = dict["IsSlide"]?.int;//"0"
        self.IsTop = dict["IsTop"]?.int;//"1"
        self.Keyword = dict["Keyword"]?.string;//"第六届全国钢结构产业发展研讨会把脉行业发展"
        self.Title = dict["Title"]?.string;//"第六届全国钢结构产业发展研讨会把脉行业发展"
        self.Title_e = dict["Title_e"]?.string;//""
        self.Zhaiyao = dict["Zhaiyao"]?.string;//"全国钢结构设计师联盟、北京市建设工..."
        self.Zhaiyao_e = dict["Zhaiyao_e"]?.string;//""
        }
    }
    
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToList(json js: JSON?)->[ArticlesItemTo]?{
        if(js == nil){
            return [];
        }
        let json = js!
        if let items = json.array {
            var results = [ArticlesItemTo]()
            for item in items {
                let result = ArticlesItemTo(jsons: item.dictionary ?? [:] )!
//                                if(result != nil){//空还加个屁啊  json为“[]” 时 这是不会为空的。除非直接来了个nil
//                                    results.append(result!)
//                                }
                results.append(result)
            }
            return results;
        }
        return [ArticlesItemTo]()
    }
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToMap(json: JSON)->Dictionary<String,ArticlesItemTo>{
        if let items = json.dictionary {
            var results = Dictionary<String,ArticlesItemTo>()//取值的时候本身就是可选类型啊,所以这里不用跟数组一样弄可选类型
            for (key, value)  in items {
                let result = ArticlesItemTo(jsons: value.dictionary )
                results[key] = result
            }
            return results;
        }
        return Dictionary<String,ArticlesItemTo>()
    }
    

    
    
    
}
import Foundation
import SwiftyJSON

//lkm
class ArticlesChannesTo: NSObject {
    
    var Id: String?;//"585"
    var Title: String?;//"政策新闻"
    var Title_e: String?;//"new1"
    var ParentId: Int?;//"0"
    var ClassList: String?;//",585,"
    var ClassLayer: Int?;//"1"
    var ClassOrder: Int?;//"1"
    var PageUrl: String?;//"../Contents/List.aspx"
    var KindId: Int?;//"1"
    var PicUrl: String?;//""
    var Comments: String?;//""
    var IsTop: Int?;//"0"
    
    //dict["data"].dictionaryObject  dict是JSON
    init?(jsons: [String: JSON]?) {
        super.init()
        if(jsons == nil){
            return nil
        }
        
        if let dict = jsons{
        
        self.Id = dict["Id"]?.string;//"585"
        self.Title = dict["Title"]?.string;//"政策新闻"
        self.Title_e = dict["Title_e"]?.string;//"new1"
        self.ParentId = dict["ParentId"]?.int;//"0"
        self.ClassList = dict["ClassList"]?.string;//",585,"
        self.ClassLayer = dict["ClassLayer"]?.int;//"1"
        self.ClassOrder = dict["ClassOrder"]?.int;//"1"
        self.PageUrl = dict["PageUrl"]?.string;//"../Contents/List.aspx"
        self.KindId = dict["KindId"]?.int;//"1"
        self.PicUrl = dict["PicUrl"]?.string;//""
        self.Comments = dict["Comments"]?.string;//""
        self.IsTop = dict["IsTop"]?.int;//"0"
        }
    }
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToList(json js: JSON?)->[ArticlesChannesTo]?{
        if(js == nil){
            return nil;
        }
        let json = js!
        if let items = json.array {
            var results = [ArticlesChannesTo]()
            for item in items {
                let result = ArticlesChannesTo(jsons: item.dictionary ?? [:])!
//                                if(result != nil){//空还加个屁啊  json为“[]” 时 这是不会为空的。除非直接来了个nil
//                                    results.append(result!)
//                                }
                results.append(result)
            }
            return results;
        }
        return [ArticlesChannesTo]()
    }
    
    //initToList( json:JSON(dict["huxing"] ) )  把JSON过的Any转为JSON
    //一定要是JSON要是 [Any] 的话 会装换失败，最后我还是选用这个JSON
    class func initToMap(json: JSON)->Dictionary<String,ArticlesChannesTo>{
        if let items = json.dictionary {
            var results = Dictionary<String,ArticlesChannesTo>()//取值的时候本身就是可选类型啊,所以这里不用跟数组一样弄可选类型
            for (key, value)  in items {
                let result = ArticlesChannesTo(jsons: value.dictionary )
                results[key] = result
            }
            return results;
        }
        return Dictionary<String,ArticlesChannesTo>()
    }
    
    
    
    
}

